import java.util.Vector;

/**
 * @version Create on 2012-10-31
 * @author Yinzi Chen
 */

public class CountAndSay {

	static Vector<Vector<Integer>> cache;

	static {
		cache = new Vector<Vector<Integer>>();
		Vector<Integer> vec = new Vector<Integer>();
		vec.add(1);
		cache.add(vec);
	}

	public String countAndSay(int n) {
		String res = "";
		int size = cache.size();
		Vector<Integer> pre = cache.get(size - 1);
		for (int i = size; i < n; ++i) {
			Vector<Integer> cur = new Vector<Integer>();
			for (int j = 0; j < pre.size(); ++j) {
				int cnt = 1;
				while (j + 1 < pre.size() && pre.get(j + 1) == pre.get(j)) {
					j++;
					cnt++;
				}
				cur.add(cnt);
				cur.add(pre.get(j));
			}
			cache.add(cur);
			pre = cur;
		}
		for (int i : cache.get(n - 1)) {
			res += i;
		}
		return res;
	}

	public static void main(String[] args) {
		Vector<Vector<Integer>> cache = new Vector<Vector<Integer>>();
		Vector<Integer> pre = new Vector<Integer>();
		Vector<Integer> cur = new Vector<Integer>();
		cur.add(1);
		cache.add(cur);
		// cur.clear();
		System.out.println(cache.get(0).size());
	}

}
